<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>产品详情管理</title>
<meta name="decorator" content="default"/>
	<script type="text/javascript" src="/jeesite/static/jquery-tablesorter/jquery.tablesorter.js"></script>
	<link href="/jeesite/static/jquery-tablesorter/themes/blue/style.css" rel="stylesheet" type="text/css">
	<script type="text/javascript">
	$(document).ready(
			function() {
				$("#btnExport").click(
						function() {
							top.$.jBox.confirm("确认要导出产品数据吗？", "系统提示", function(
									v, h, f) {
								if (v == "ok") {
									$("#searchForm").attr("action",
											"${ctx}/pro/productInfo/export");
									$("#searchForm").submit();
								}
							}, {
								buttonsFocus : 1
							});
							top.$('.jbox-body .jbox-icon').css('top', '55px');
						});
				$("#btnImport").click(function() {
					$.jBox($("#importBox").html(), {
						title : "导入数据",
						buttons : {
							"关闭" : true
						},
						bottomText : "导入文件不能超过5M，仅允许导入“xls”或“xlsx”格式文件！"
					});
				});
			});
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").attr("action", "${ctx}/pro/productInfo/list");
		$("#searchForm").submit();
		return false;
	}

	//删除
	function deleteData() {
		var $id = $("input[name='id']:checked");
		var ids = new Array();
		var j = 0;
		if ($id.val() != null && $id.val() != '') {
			var submit = function(v, h, f) {
				if (v == 'ok') {
					$id.each(function(i, info) {
						ids[j] = info.value;
						j++;
					});
					resetTip();
					location.href = "${ctx}/pro/productInfo/deleteData?ids="
							+ ids;
				} else if (v == 'cancel') {
					return true;
				}
			};
			$.jBox.confirm("确认删除选中的信息吗？", "提示", submit);
		} else {
			jBox.tip("请勾选需要删除的数据！");
		}
	}
	$(document)
			.ready(
					function() {
						//全选
						$("#checkAll").click(
								function() {
									$('input[name="id"]').attr("checked",
											this.checked);
								});
						var $subBox = $("input[name='id']");
						$subBox
								.click(function() {
									$("#checkAll")
											.attr(
													"checked",
													$subBox.length == $("input[name='id']:checked").length ? true
															: false);
								});
					});
</script>
</head>
<body class="fixed-top">
	<div class="container" style="width: 100%;">
		<div style="margin: 20px; border: 1px solid #c8d1d5;">
			<div id="importBox" class="hide">
				<form id="importForm" action="${ctx}/pro/productInfo/import"
					method="post" enctype="multipart/form-data" class="form-search"
					style="padding-left: 20px; text-align: center;"
					onsubmit="loading('正在导入，请稍等...');">
					<br /> <input id="uploadFile" name="file" type="file"
						style="width: 330px" /><br /> <br /> <input
						id="btnImportSubmit" class="btn btn-primary" type="submit"
						value="   导    入   " /> <a
						href="${ctx}/pro/productInfo/import/template">下载模板</a>
				</form>
			</div>
			<div
				style="padding: 13px; background-color: #f4f4f4; border-bottom: 1px solid #c8d1d5;">
				<h4>
					<i class="icon-globe"></i>产品管理
				</h4>
				<ul class="ul-form" style="float: right; margin-top: -25px;">
					<li style="list-style: none"><a class="btn btn-primary"
						href="${ctx}/pro/productInfo/form"> <i class="icon-pencil"></i>&nbsp;新增
					</a> <a class="btn btn-danger" href="javascript:void(0)"
						onclick="deleteData()"> <i class="icon-trash"></i>&nbsp;删除
					</a> <a class="btn btn-info" href="javascript:void(0)" id="btnImport">
							<i class="icon-upload"></i>&nbsp;导入
					</a> <a class="btn btn-info" href="javascript:void(0)" id="btnExport">
							<i class="icon-download"></i>&nbsp;导出
					</a></li>
				</ul>
			</div>
			<div style="margin: 17px;">
				<form:form id="searchForm" modelAttribute="productInfo"
					action="${ctx}/pro/virtualDetail/list" method="post"
					class="breadcrumb form-search">
					<input id="pageNo" name="pageNo" type="hidden"
						value="${page.pageNo}" />
					<input id="pageSize" name="pageSize" type="hidden"
						value="${page.pageSize}" />
					<ul class="ul-form">
						<li><label style="width: 100px;">产品编号：</label> <form:input path="codeNum"
								htmlEscape="false" maxlength="64" class="input-medium" /></li>
						<li><label  >产品类型：</label> 
						<form:input path="productTypeName" maxlength="64" class="input-medium" />
						</li>
						<li><label>产品名称：</label> <form:input path="name"
								htmlEscape="false" maxlength="64" class="input-medium" /></li>
						<li><label>规格：</label> <form:input path="specifications"
								htmlEscape="false" maxlength="64" class="input-medium" /></li>
						<li><label>产品代码：</label> <form:input path="productCode"
								htmlEscape="false" maxlength="64" class="input-medium" /></li>

						<li class="btns"><input id="btnSubmit"
							class="btn btn-primary" type="submit" value="查询"
							onclick="return page();" /> </li>
					</ul>
				</form:form>
				<sys:message content="${message}" />
				<table id="contentTable" class="table table-hover table-bordered" style="word-wrap:break-all;word-break:break-all;">
					<thead>
						<tr>
							<th><input type="checkbox" class="group-checkable" id="checkAll" /></th>
							<th>产品编号</th>
							<th>产品名称</th>
							<th>产品代码</th>
							<th>产品类型</th>
							<th>品牌</th>
							<th>封装</th>
							<th>规格</th>
							<th>计量单位</th>
							<th>是否预警</th>
							<th>预警上限</th>
							<th>预警下限</th>
							<th>备注</th>
							<th>更新时间</th>
							<shiro:hasPermission name="pro:productInfo:edit">
								<th>操作</th>
							</shiro:hasPermission>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${page.list}" var="productInfo">
							<tr>
								<td style="width: 8px;"><input type="checkbox" name="id"
									class="group-checkable" value="${productInfo.id}" /></td>
									<td>${productInfo.codeNum}</td>
								<td>${productInfo.name}</td>
								<td>${productInfo.productCode}</td>
								<td>${productInfo.productTypeName}</td>
								<td>${productInfo.brand}</td>
								<td>${productInfo.packaging}</td>
								<td>${productInfo.specifications}</td>
								<td>${productInfo.unitName}</td>
								<td><c:choose>
										<c:when test="${productInfo.warning=='1'}"><i class="icon-ok" style="color: red;"></i></c:when>
										<c:when test="${productInfo.warning=='0'}"><i class="icon-remove"></i></c:when>
									</c:choose></td>
								<td>${productInfo.upperLimit}</td>
								<td>${productInfo.lowerLimit}</td>
								<td>${productInfo.remarks}</td>
								<td><fmt:formatDate value="${productInfo.updateDate}"
										pattern="yyyy-MM-dd HH:mm:ss" /></td>
								<shiro:hasPermission name="pro:productInfo:edit">
									<td><a
										href="${ctx}/pro/productInfo/form?id=${productInfo.id}"><i class="icon-edit"></i></a>
										<a
										href="${ctx}/pro/productInfo/deleteData?ids=${productInfo.id}"
										onclick="return confirmx('确认要删除该合同号吗？', this.href)"><i class="icon-remove"></i></a></td>
								</shiro:hasPermission>
							</tr>
						</c:forEach>
					</tbody>
				</table>
				<div class="pagination">${page}</div>
			</div>
		</div>
	</div>
</body>
</html>